home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / Drill Designer 1.1 / Demo Programs / Recycle C Folder / Recycle C.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-11  |  16.8 KB  |  478 lines  |  [TEXT/KAHL]

  1. #include "Drill Designer.h"                    /* includes definitions needed */
  2.  
  3. char *PATH_NAME = "Drill Designer Disk:";/* not 'relocatable', but Recycle C Appl is */
  4. global_ptr        dp=NULL;
  5.  
  6. #define total_Questions            80
  7. #define initial_queue_Length    10
  8.  
  9.  
  10. /*************  List of questions *******************/
  11.  
  12. struct quest_Rec
  13. {    char *        question_Str;
  14.     char        correct_Ans;
  15. }    
  16.     question_Data [total_Questions+1] = 
  17.     {"",' ',            /* dummy 0th question */
  18.     
  19.     
  20. /****************************** Garbage, recycling *******************************/
  21.  
  22. "How many tons of garbage are produced annually by \n\
  23.  American households?\n\
  24.  \tA. 94 million tons \n\tB. 124 million tons\n\
  25.  \tC. 154 million tons",                                    'C',
  26.  
  27. "How many pounds of garbage will Americans generate today?\n\
  28. \tA. 8.4 million\n\tB. 84.4 million\n\tC. 844 million",        'C',
  29.  
  30. "What percentage of the trash produced by Americans is \n\
  31.  recyclable?\n\
  32.  \tA. 30%\n\tB. 50%\n\tC. 70%",                                'B',
  33.  
  34. "The U.S. recycles what percentage of its trash?\n\
  35.  \tA. less than 10%\n\tB. 35%\n\tC. 60%",                    'A',
  36.  
  37. "European countries recycle what percentage of their trash?\n\
  38.  \tA. less than 10%\n\tB. 35%\n\tC. 60%",                    'C',        /* 5 */
  39.  
  40. "How long does it take for a citizen of an advanced,\n\
  41. industrialized country to consume the energy and raw materials\n\
  42. that have to last a citizen of a developing country an entire\n\
  43. lifetime?\n\
  44. \tA. 6 months\n\tB. 3 years\n\tC. 12 years",                'A',
  45.  
  46. "According to recent research, approximately how many newspapers\n\
  47. will be printed in America today?\n\
  48. \tA. 62,500,000\n\tB. 75,000,000\n\tC. 123,000,000",        'A',    
  49.  
  50. "In 1988 how much of the paper used by Americans was recycled?\n\
  51. \tA. 15%\n\tB. 29%\n\tC. 38%",                                'B',        
  52.  
  53. "According to recent research, about how many glass containers\n\
  54.  will Americans use today?\n\
  55.  \tA. 53 million\n\tB. 107 million\n\tC. 126 million",        'C',
  56.  
  57. "How much of the glass used by Americans in 1988 was recycled?\n\
  58.  \tA. 27%\n\tB. 34%\n\tC. 42%",                                'A',    /* 10 */    
  59.  
  60. "How much plastic is used by each American per year?\n\
  61. \tA.  60 pounds\n\tB. 190 pounds\n\tC. 340 pounds",            'B',
  62.  
  63. "How many plastic soda bottles are discarded by Americans \n\
  64. every HOUR?\n\
  65. \tA. 250,000\n\tB. 2.5 million\n\tC. 5 million",            'B',
  66.  
  67. "How many pounds of plastic could be saved from landfills each year\n\
  68. if 10% of Americans purchase products with less packaging just\n\
  69. 10% of the time?\n\
  70. \tA. 110 million pounds\n\tB. 144 million pounds\n\
  71. \tC. 163 million pounds",                                    'B',    
  72.  
  73. "How long does it take Americans to throw away enough aluminum \n\
  74. to rebuild our entire commercial airfleet?\n\
  75. \tA. 3 months\n\tB. 1 year\n\tC. 2 years",                    'A',    
  76.  
  77. "How many million tons of aluminum have been recycled and \n\
  78. therefore saved from the landfills since 1972?\n\
  79. \tA. 1 million tons\n\tB. 5 million tons\n\
  80. \tC. 10 million tons",                                         'B',    /* 15 */
  81.  
  82. "How many years have we had the technology to recycle the 30 billion\n\
  83. steel and tin cans that are disposed of in landfills each year?\n\
  84. \tA. 20 years\n\tB. 40 years\n\tC. 60 years",                'C',
  85.  
  86. "According to recent research, about how much advertising\n\
  87. mail will be delivered to American homes TODAY?\n\
  88. \tA. 1,100 tons\n\tB. 3,300 tons\n\tC. 5,500 tons",            'C',
  89.  
  90. "On the average, how much third class mail does each American\n\
  91. receive each year?\n\
  92. \tA. 179 pieces\n\tB. 248 pieces\n\tC. 354 pieces",            'B',
  93.  
  94. "By conservative estimates, how much mail will pass through \n\
  95. American post offices today?\n\
  96. \tA. At least 100 million pieces\n\tB. At least 200 million pieces\n\
  97. \tC. At least 350 million pieces",                            'C',    
  98.  
  99. "According to recent research, about how many catalogs will \n\
  100. Americans receive in the mail today?\n\
  101. \tA. 1 million\n\tB. 20 million\n\tC. 300 million",            'B',    /* 20 */
  102.  
  103.  
  104.  
  105. /***************** cars, driving, etc *********************************/
  106. "How many gallons of gasoline will American cars consume today?\n\
  107. \tA. 30 million\n\tB. 200 million\n\tC. 1 billion",            'B',
  108.  
  109. "In 1987, how much gas did the average car use compared to 1978?\n\
  110. \tA. 43% less\n\tB. 14% less\n\tC. 21% more",                'A',
  111.  
  112. "How many cars are registered in the U.S.?\n\
  113. \tA. 25 million\n\tB. 82 million\n\tC. 140 million",        'C',        
  114.  
  115. "In the U. S. how many miles is the average car driven per year?\n\
  116. \tA. 2,000 miles\n\tB. 12,000 miles\n\tC. 22,000 miles",     'B',
  117.  
  118. "How many miles do Americans drive every year total?\n\
  119. \tA. 1 billion\n\tB. 100 billion\n\tC. more than 1 trillion",  'C',        /* 25 */
  120.  
  121. "According to recent research, how many miles will Americans\n\
  122. drive today?\n\
  123. \tA. 1 million\n\tB. 100 million\n\tC. 4 billion",            'C',    
  124.  
  125. "What percentage of all miles traveled by Americans is by car?\n\
  126. \tA. 55%\n\tB. 68%\n\tC. 80%",                                'C',    
  127.  
  128. "Americans own what percentage of the 400 million cars found \n\
  129. worldwide?\n\
  130. \tA. 22%\n\tB. 35%\n\tC. 51%",                                'B',
  131.  
  132. "If all cars were this fuel efficient, the U.S. would not\n\
  133. have to import any oil:\n\
  134. \tA. 42 mpg\n\tB. 54 mpg\n\tC. 78 mpg",                        'A',
  135.  
  136. "In 1990, the highest-rated commercially available car got how \n\
  137. many mpg in the city?\n\
  138. \tA. 37 mpg\n\tB. 42 mpg\n\tC. 53 mpg",                        'C',        /* 30 */
  139.  
  140.  
  141.  
  142.  
  143. /**************************** Auto-related stuff ********************************/
  144.  
  145.  
  146. "How many gallons of oil did the supertanker EXXON VALDEZ\n\
  147. spill when it ran aground in Alaska on 3/24/89?\n\
  148. \tA. 1.6 million\n\tB. 10.8 million\n\tC. 50.3 million",    'B',
  149.  
  150. "About how many automobile tires will be manufactured in \n\
  151. American factories today?\n\
  152. \tA. 260,000\n\tB. 480,000\n\tC. 680,000",                    'C',
  153.  
  154. "How much motor oil is used by Americans every year?\n\
  155. \tA. 1 billion gallons\n\tB. 5 billion gallons\n\
  156. \tC. 10 billion gallons",                                    'A',
  157.  
  158. "According to recent research, about how many auto batteries will \n\
  159. Americans replace today?\n\
  160. \tA. 150,000\n\tB. 500,000\n\tC. 1 million",                'A',        
  161.  
  162.  
  163. /*********************** carbon dioxide, etc ****************************/
  164.  
  165. "How much carbon dioxide is released into the atmosphere\n\
  166. for every gallon of gas burned by a car?\n\
  167. \tA. 2 ounces\n\tB. 2 pounds\n\tC. 20 pounds",                'C',        /* 35 */
  168.  
  169. "How much more carbon dioxide is in the atmosphere now than a \n\
  170. century ago from constant burning of fossil fuels?\n\
  171. \tA. 10% more\n\tB. 18% more\n\tC. 25% more",                'C',
  172.  
  173. "How many pounds of carbon dioxide is consumed by a mature tree\n\
  174. in a year?\n\
  175. \tA. 6 pounds\n\tB. 13 pounds\n\tC. 21 pounds",                'B',
  176.  
  177. /***************************** refrigerators *********************************/
  178.  
  179. "If you live in a city your refrigerator can account for how much \n\
  180. of the energy that you use?\n\
  181. \tA. 7%\n\tB. 18%\n\tC. 25%",                                'C',
  182.  
  183. "It is more energy efficient to keep your refrigerator or freezer:\n\
  184. \tA. empty\n\tB. full\n\tC. upside-down",                    'B',
  185.  
  186. "About how many new refrigerators will Americans buy today?\n\
  187. \tA. 10,000\n\tB. 12,000\n\tC. 15,000",                      'B',    /* 40 */
  188.  
  189. /************************** Lighting ******************************************/
  190.  
  191. "When you are leaving a room for just a few minutes, you should\n\
  192.  \tA. turn the light off to save energy\n\tB. leave the light on;\n\
  193.  \tit uses more energy to turn it off and on again",        'A',
  194.  
  195.  "A LONG-LIFE incandescent bulb is more energy-efficient than a \n\
  196.  standard bulb.\n\
  197.  \tA. True\n\tB. False; it is less energy-efficient\n\
  198.  \tC. They use about the same amount of energy.",            'B',    
  199.  
  200. "Lighting and air conditioning consume what percentage of the \n\
  201. electricity used in a commercial building?\n\
  202. \tA. 20%\n\tB. 40%\n\tC. 60%",                                'C',
  203.  
  204. "Which will give you the most light in a multi-bulb fixture?\n\
  205. \tA A. single 100-watt bulb\n\tB. Four 25-watt bulbs\n\
  206. \tC. A candle",                                                'A',
  207.  
  208. /*********************** Household stuff *******************************/
  209.  
  210. "According to recent research, about how many tons of BOXES, BAGS,\n\
  211. and WRAPPERS will Americans discard today?\n\
  212. \tA. 150,000\n\tB. 500,000\n\tC. 1 million",                'A',        /* 45 */
  213.  
  214. "According to recent research, about how many disposable diapers\n\
  215. will Americans throw out today?\n\
  216. \tA. 490,000\n\tB. 4.9 million\n\tC. 49 million",            'C',    
  217.  
  218. "How many gallons of paint do Americans use every day?\n\
  219. \tA. 3 million\n\tB. 7 million\n\tC. 11 million",            'A',
  220.  
  221. "Which type of paint is considered better for the environment?\n\
  222. \tA. latex\n\tB. oil-based\n\tC. stain",                    'A',
  223.  
  224. "The amount of energy that escapes through American windows and\n\
  225. doors every winter is equivalent to what percentage of the oil\n\
  226. that flows through the Alaska pipeline each year?\n\
  227. \tA. 40%\n\tB. 75%\n\tC. 100%",                                'C',
  228.  
  229. "In the average American house, all of the gaps around windows\n\
  230. and doors could combine to form a hole in the wall of what area?\n\
  231. \tA. 3 inches x 3 inches\n\tB. 3 feet x 3 feet\n\
  232. \tC. 3 yards x 3 yards",                                    'B',        /* 50 */
  233.  
  234.  
  235. "What is the proper length for grass when cutting?\n\
  236. \tA. 1-2 inches\n\tB. 2-3 inches\n\tC. 3-4 inches",            'B',        
  237.  
  238.  
  239.  
  240.  
  241.  
  242. /********************** water conservations etc *****************************/
  243.  
  244.  
  245. "How many gallons of water a week can you save by watering \n\
  246. grass, plants and trees in the early morning?\n\
  247. \tA. 12 gallons\n\tB. 25 gallons\n\tC. 50 gallons",            'C',    
  248.  
  249. "How much of the water used in our homes is consumed in the bathroom?\n\
  250. \tA. 35%\n\tB. 55%\n\tC. 75%",                                'C',
  251.  
  252. "How much of the water used in homes is used in taking showers?\n\
  253. \tA. 30%\n\tB. 50%\n\tC. 70%",                                'A',
  254.  
  255. "When taking a bath as opposed to a shower, how much water is used?\n\
  256. \tA. 5 times the amount\n\tB. 3 times the amount\n\
  257. \tC. about the same amount",                                'B',
  258.  
  259. "Which method of washing dishes uses the least amount of water?\n\
  260. \tA. Washing dishes by hand with the water running\n\
  261. \tB. Washing dishes by hand using wash and rinse basins only\n\
  262. \tC. Washing dishes in a dishwasher",                        'B',    
  263.  
  264. "If a leak fills a coffee cup in 10 minutes how much water\n\
  265. will it waste in a year?\n\
  266. \tA. 365 gallons\n\tB. 1,000 gallons\n\
  267. \tC. 3,000 gallons",                                        'C',
  268.  
  269. "According to recent research, approximately how many gallons\n\
  270. of pure water will Americans flush down their toilets today?\n\
  271. \tA. 1.5 billion\n\tB. 3.5 billion\n\tC. 6.5 billion",        'C',        
  272.  
  273.  
  274.  
  275. "How many of the houses in Cyprus have solar hot water systems?\n\
  276. \tA. 35%\n\tB. 65%\n\tC. 90%",                                'C',        
  277.  
  278. "How much of the Israelis' hot water is produced by solar energy?\n\
  279. \tA. 35%\n\tB. 65%\n\tC. 90%",                                'B',        /* 60 */
  280.     
  281. /******************* Toxic pollution, etc., ************************/ 
  282.  
  283.  
  284. "What amount of toxic chemicals per acre of land are used by\n\
  285. the average homeowner in comparison to farmers?\n\
  286. \tA. homeowners use 10 times more chemicals\n\
  287. \tB. they use about the same amount\n\
  288. \tC. farmers use 10 times more chemicals",                    'A',
  289.  
  290. "Most Americans have styrene in their fat tissue from using\n\
  291. polystyrene plates and cups.\n\
  292. \tA. True\n\tB. False",                                        'A',        
  293.  
  294. "Name a common preservative of non-organic fresh mushrooms:\n\
  295. \tA. nitrates\n\tB. monosodium glutamate\n\tC. formaldahyde",  'C',
  296.  
  297. "According to the EPA, how much hazardous waste is produced every\n\
  298. year, for every man, woman and child, in the U.S.?\n\
  299. \tA. 12 pounds\n\tB. about 150 pounds\n\tC. over 1 ton",    'C',
  300.  
  301.  
  302.  
  303. "April 28 is the anniversary of the accident at Chernobyl which \n\
  304. demonstrated the environmental threat of nuclear power plants.\n\
  305. The radiation released into the atmosphere was:\n\
  306. \tA. About equal to the amount released when the A-bomb was\n\
  307. \t   dropped on Hiroshima\n\tB. Twice as great as Hiroshima\n\
  308. \tC. About 90 times greater than Hiroshima",                'C',
  309.  
  310. "Many pesticides are banned in our country but are still produced here to be\n\
  311. shipped to other countries.  What percentage of imported coffee beans tested\n\
  312. had illegally high residues of these pesticides?\n\
  313. \tA. 12%\n\tB. 33%\n\tC. 45%",                                'C',        
  314.  
  315. "According to recent research, about how much hazardous waste will\n\
  316. be produced in America today?\n\
  317. \tA. 1.5 million pounds\n\tB. 1.5 billion pounds\n\
  318. \tC. 1.5 trillion pounds",                                    'B',
  319.  
  320. "According to recent research, about how many dogs and cats will die\n\
  321. from pesticide poisoning today?\n\
  322. \tA. 10\n\tB. 50\n\tC. 80",                                    'C',        
  323.  
  324. "When a detergent label reads 8% phosphorous what is the actual\n\
  325. percentage of phosphates in the product?\n\
  326. \tA. 8%\n\tB. 16%\n\tC. 24%",                                'C',
  327.  
  328. "How much toxic mercury does America produce every year?\n\
  329. \tA. 300 gallons\n\tB. 5,000 gallons\n\tC. 100,000 gallons\n", 'C',    /* 70 */
  330.  
  331.  
  332.  
  333.  
  334.  
  335. /*************************** Conservation, wildlife *********************************/
  336.  
  337. "How many elephants are there today compared to 10 years ago,\n\
  338. due to habitat loss and poaching?\n\
  339. \tA. 10% fewer\n\tB. 25% fewer\n\tC. 50% fewer",            'C',
  340.  
  341. "About how many ivory ornamental items were Americans importing every\n\
  342. day during the 1980's?\n\
  343. \tA. 150 items\n\tB. 1,500 items\n\tC. 3,000 items",        'C',        
  344.  
  345. "How many paper grocery bags can be made from a 15-year-old tree?\n\
  346. \tA. 700 bags\n\tB. 1,000 bags\n\tC. 1,300 bags",            'A',
  347.  
  348. "One tree is saved by recycling this amount of paper:\n\
  349. \tA. 20 pounds\n\tB. 120 pounds\n\tC. 1,240 pounds",        'B',
  350.  
  351. "What percentage of the plants identified as being helpful in \n\
  352. treating cancer are found only in rainforests?\n\
  353. \tA. 26%\n\tB. 57%\n\tC. 70%",                                'C',        
  354.  
  355. "According to recent research, about how much land will be paved over\n\
  356. in America today?\n\
  357. \tA. 200 acres\n\tB. 2,750 acres\n\tC. 1 million acres",    'B',
  358.  
  359. "The commercial fishing fleet loses about how many pounds of\n\
  360. indestructible plastic fishing lines and nets every year?\n\
  361. \tA. 300 million\n\tB. 500 million\n\tC. 1 billion",        'A',
  362.  
  363. "How much packaging material is DUMPED into the sea by\n\
  364. commercial fishing fleets each year?\n\
  365. \tA. 100,000  pounds\n\tB. 6 million pounds\n\
  366. \tC. 52 million pounds\n",                                    'C',
  367.  
  368. "According to recent research, about how much American cropland \n\
  369.  will be lost to soil erosion today?\n\
  370. \tA. 150 acres\n\tB. 5,500 acres\n\tC. 11,000 acres",        'C', 
  371.  
  372. "According to DIET FOR A NEW AMERICA, how many people could be\n\
  373. fed by the grain and soybeans eaten by U.S. livestock every year?\n\
  374. \tA. 500 thousand\n\tB. 1 million\n\tC. 1 billion",            'C',
  375.  
  376.  
  377. };
  378.     
  379. /******************* End of questions list *****************/
  380.  
  381. char    done = 0;
  382. short    q_Num;
  383. char    answer = '\0';
  384. char *  dummy;
  385. char    Name[256];
  386. long    temp1, temp2;
  387. char    hard_Items;
  388.  
  389. short    Char_OK (char test_Char)
  390. {    char    OK_List[6] = {'A','B','C','Q','S'};
  391.     short    test = -1, finito = 0;
  392.     
  393.     while (++test < 5 && !finito)
  394.         if (test_Char == OK_List[test])
  395.             finito = 1;
  396.     
  397.     return (finito);
  398. }
  399.     
  400.  
  401. main()
  402. {    printf ("\t\t\tRecycling and Pollution Drill\n\n\n");
  403.     printf  ("   Questions from Simple Things You Can Do to Save the Earth 1991 Calendar\n");
  404.     printf  ("          published by Andrews and McMeel, Universal Press Syndicate\n\n\n");
  405.     printf ("Enter your name:");
  406.     scanf ("%s", Name);
  407.     while (getchar () != '\n');
  408.     printf ("\n\nWelcome, %s.", Name);
  409.     while (answer != 'Y' && answer != 'N')
  410.     {    printf ("\nWould you like to restore a previous drill (Y,N) ?");
  411.         answer = toupper (getchar ());
  412.         while (answer!= '\n' && getchar()!= '\n');
  413.     }
  414.     printf ("\n\n");
  415.     if (answer == 'Y')
  416.     {    printf ("Restoring old drill...\n\n");
  417.         dummy = Restore (&dp, Name, "Recycle");
  418.         if (strcmp (dummy, "Recflag"))
  419.         {    printf ("Sorry, could not restore drill...creating new one.\n\n");
  420.             answer = 'N';
  421.         }
  422.     }
  423.     if (answer == 'N')
  424.         CreateDrill(&dp,initial_queue_Length,1,total_Questions,'S',
  425.                 "EC","3 7 12",initial_queue_Length, "10000");
  426.      
  427.     while (!done && (q_Num = Next (dp)))
  428.     {    printf ("%u. %s\n\n", q_Num, question_Data[q_Num].question_Str);
  429.         answer = '\0';
  430.         while (!Char_OK(answer))
  431.         {    printf ("Your answer (S=store, Q=quit without storing):");
  432.             answer = toupper (getchar ());
  433.             if (answer != '\n')
  434.                 while (getchar() != '\n');
  435.         }
  436.         printf ("\n");
  437.         if (answer == 'Q')
  438.             done = 1;
  439.         else if (answer == 'S')
  440.         {    printf ("Storing this drill...\n");
  441.             Store (dp, Name, "Recycle", "Recflag");
  442.         }
  443.         else if (answer == question_Data[q_Num].correct_Ans)
  444.         {    Correct (dp);
  445.             printf ("That is correct!!!!\n");
  446.         }
  447.         else
  448.         {    printf ("Sorry, that is incorrect.  The correct answer is %c.\n",
  449.                     question_Data[q_Num].correct_Ans);    
  450.             Incorrect (dp);
  451.         }
  452.         printf ("\n");
  453.     
  454.     }
  455.     printf ("\n\n\n\n\n");
  456.     printf ("\t\t\t\tYour cumulative results\n\n");
  457.     temp1 = RetrieveInfo (dp, 19);
  458.     temp2 = temp1 % 60;
  459.     temp1 = temp1 / 60;
  460.     printf ("\tTime spent in drill:%ld minutes %ld seconds\n\n", temp1, temp2);
  461.     temp1 = RetrieveInfo (dp, 10);        /* Total questions answered */
  462.     temp2 = RetrieveInfo (dp, 12);        /* Total correct */
  463.     printf ("\tNumber of questions correct: %ld\n\n", temp2);
  464.     printf ("\tNumber of questions missed: %ld\n\n", temp1 - temp2);
  465.     printf ("\tPercent correct: %ld\n\n", RetrieveInfo (dp, 14));
  466.     hard_Items = RetrieveInfo (dp, 21, 5, '%');
  467.     if (hard_Items)
  468.     {    printf ("\tHardest questions:\n");
  469.         printf ("\t\t#  Question:\t\t%% of times missed\n");
  470.         for (temp1 =1; temp1 <= hard_Items; temp1++)
  471.         {    temp2 = RetrieveInfo (dp, 22, (short) temp1); /* must cast! "short" must be passed! */
  472.             printf ("\t\t%ld. %2ld\t\t\t\t", temp1, temp2);
  473.             printf ("%3ld\n", RetrieveInfo (dp, 9, (short) temp2)); /* ditto! */
  474.         }
  475.     }
  476.     
  477.     Dispose (&dp);
  478. }